﻿using Slippor.Douban.Radio.Assist;
using System.Web;
using System.Text;
using System;
using Slippor.Douban.Radio.Tracker;

namespace MsnTrackerPlugin
{
    public class MsnTracker : ITracker
    {
        public MsnTracker()
        {
        }

        #region ITracker Members
        private const String _key = "MSN";
        public string Name
        {
            get { return _key; }
        }

        public void Track(Song song)
        {
            SendMessage(song);
        }

        public void TrackUpdate(ICommand command, Song song)
        {
            if (song != null)
            {
                switch (command.Command)
                {
                    case Command.Other:
                        SendMessage(song);
                        break;
                    default:
                        break;
                }
            }
        }

        private static void SendMessage(Song song)
        {
            if (song.Album != null)
            {
                Utility.SendMSNMessage(true, "Music", String.Format("{0} - {1}",
                                                         song.Title, song.Album.ArtistString));
            }
            else
            {
                Utility.SendMSNMessage(true, "Music", String.Format("{0} - {1}",
                                                                     song.Title, "豆瓣电台"));
            }
        }

        public void Clear()
        {
            Utility.SendMSNMessage(false, "Music", String.Empty);
        }

        public void Stop()
        {
            Utility.SendMSNMessage(false, "Office", String.Empty);
        }

        public void Pause()
        {
        }

        public void Resume()
        {
        }
        #endregion
    }
}